using System;
using System.Threading.Tasks;
using BangleAbp.Permissions;
using BangleAbp.Products.Dtos;
using Microsoft.AspNetCore.Authorization;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;

namespace BangleAbp.Products
{
    public class ProductAppService : CrudAppService<Product, ProductDto, Guid, PagedAndSortedResultRequestDto, CreateUpdateProductDto>,
        IProductAppService
    {
        private readonly IProductRepository _repository;

        public ProductAppService(IProductRepository repository) : base(repository)
        {
            _repository = repository;
        }

        [Authorize(BangleAbpPermissions.ProductCreate)]
        public override Task<ProductDto> CreateAsync(CreateUpdateProductDto input)
        {
            return base.CreateAsync(input);
        }

        [Authorize(BangleAbpPermissions.ProductDelete)]
        public override Task DeleteAsync(Guid id)
        {
            return base.DeleteAsync(id);
        }

        [Authorize(BangleAbpPermissions.Product)]
        public override Task<ProductDto> GetAsync(Guid id)
        {
            return base.GetAsync(id);
        }

        [Authorize(BangleAbpPermissions.Product)]
        public override Task<PagedResultDto<ProductDto>> GetListAsync(PagedAndSortedResultRequestDto input)
        {
            return base.GetListAsync(input);
        }

        [Authorize(BangleAbpPermissions.ProductUpdate)]
        public override Task<ProductDto> UpdateAsync(Guid id, CreateUpdateProductDto input)
        {
            return base.UpdateAsync(id, input);
        }
    }
}